package com.coin.liu.controller;

import com.coin.liu.Service.UserInfoService;
import com.coin.liu.pojo.userData.Jurisdiction;
import com.coin.liu.pojo.userData.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/userInfo")
public class UserInfoController {
    /*
    * 新增权限
    * */
    @Autowired
    private UserInfoService userInfoService;
    @GetMapping("/Jurisdiction")
    public String listUploadedFiles(){
        return "userInfoJurisdiction1";
    }
    @RequestMapping("/addJurisdiction")
    public String addJurisdiction(Jurisdiction jurisdiction){
        userInfoService.addJurisdiction(jurisdiction);
        return null;
    }
    @RequestMapping("/updateJurisdiction")
    public String updateJurisdiction(String value,String id,String field){
        userInfoService.updateJurisdiction(value,id,field);
        return null;
    }
    @RequestMapping("/findAllJurisdiction")
    @ResponseBody
    public Map findAllJurisdiction(){
        List<Jurisdiction> allData = userInfoService.findAllJurisdiction();
        Map map=new HashMap<>();
        map.put("code",0);
        map.put("msg","成功");
        map.put("count",allData.size());
        map.put("data",allData);
        return map;
    }
    @RequestMapping("/findAllUserInfo")
    @ResponseBody
    public Map findAllUserInfo(){
        List<UserInfo> allData = userInfoService.findAllUserInfo();
        Map map=new HashMap<>();
        map.put("code",0);
        map.put("msg","成功");
        map.put("count",allData.size());
        map.put("data",allData);
        return map;
    }
    @GetMapping("/userInfoData")
    public String userInfoData(){
        return "userInfo";
    }
    @RequestMapping("/addUserInfo")
    public String addUserInfo(Jurisdiction jurisdiction){
        userInfoService.addUserInfo(jurisdiction);
        return null;
    }
    @RequestMapping("/updateUserInfo")
    public String updateUserInfo(String value,String id,String field){
        userInfoService.updateUserInfo(value,id,field);
        return null;
    }
}
